home *** CD-ROM | disk | FTP | other *** search
- /* Compound if and else-if statements. */
- using System;
-
- namespace Chapter2 {
- class Class1 {
- static void Main() {
- string input;
- float MyNumber;
-
- Console.Write("How old are you? ");
- input = Console.ReadLine();
- MyNumber = float.Parse(input);
-
- if (MyNumber >= 18)
- Console.WriteLine("You're an adult\n" + "You can vote\n");
- else if (MyNumber == 17)
- Console.WriteLine("Your turn will come \n");
- else if (MyNumber == 16) { // compound statement
- Console.Write("\n Don't rush it boy you'll only be young once\n"
- + "How old are you again? ");
- input = Console.ReadLine();
- MyNumber = float.Parse(input);
- } else
- Console.WriteLine("\n You're just too young!!!\n");
- }
- }
- }
-